package com.mazaiting.classfile.attr.info;

import com.mazaiting.classfile.ClassReader;
import com.mazaiting.classfile.attr.entity.ParameterAnnotationsEntity;
import com.mazaiting.classfile.constant.ConstantPool;

import java.util.Arrays;

/**
 * 运行时可见参数注解属性
 *
 * @author mazaiting
 * @since 2021/8/13
 */
public class RuntimeVisibleParameterAnnotationsAttribute extends AttributeInfo{
    /**
     * 参数数量 无符号 u1
     */
    private short numParameters;
    /**
     * 参数注解实体
     */
    private ParameterAnnotationsEntity[] parameterAnnotationEntities;

    public RuntimeVisibleParameterAnnotationsAttribute(ConstantPool pool, int index, int length) {
        super(pool, index, length);
    }

    @Override
    public void readInfo(ClassReader reader) {
        this.numParameters = reader.readU1ToUnsignedByte();
        this.parameterAnnotationEntities = new ParameterAnnotationsEntity[numParameters];
        for (int i = 0; i < numParameters; i++) {
            this.parameterAnnotationEntities[i] = new ParameterAnnotationsEntity(reader, pool);
        }
    }

    @Override
    public String toString() {
        return "RuntimeVisibleParameterAnnotationsAttribute{" +
                "nameIndex=" + nameIndex +
                ", length=" + length +
                ", numParameters=" + numParameters +
                ", parameterAnnotationEntities=" + Arrays.toString(parameterAnnotationEntities) +
                '}';
    }
}


















